package com.xique.park.api.factory;


import com.xique.common.core.web.domain.AjaxResult;
import com.xique.park.api.RemoteParkInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @author xique
 */
@Component
public class RemoteParkInfoFallbackFactory implements FallbackFactory<RemoteParkInfoService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteParkInfoFallbackFactory.class);

    @Override
    public RemoteParkInfoService create(Throwable throwable)
    {
        log.error("停车服务调用失败:{}", throwable.getMessage());

        return new RemoteParkInfoService()
        {
            @Override
            public AjaxResult initParkInfo(Long parkId) {
                return AjaxResult.error("初始化停车信息失败:" + throwable.getMessage());
            }
        };

    }
}
